package team.yidong.fenda.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import team.yidong.fenda.entity.MasterScore;

import java.util.Date;
import java.util.List;

/**
 * Created by xuanlong on 2017/10/29.
 */
public interface MasterScoreRepository extends JpaRepository<MasterScore, Integer>, JpaSpecificationExecutor<MasterScore> {
    @Query("select masterScore from MasterScore masterScore join masterScore.masterScoreAnswer answer join answer.master master where master.id=?1 and masterScore.status=?2")
    List<MasterScore> findByStatusAndMaster(Integer masterId, String status);

    @Query("select sum(masterScore.num) from MasterScore masterScore join masterScore.masterScoreAnswer answer join answer.master master where master.openId=?1 and masterScore is not null ")
    double sumMasterScore(String openid);
}
